import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-03-14
 * Time: 19:16
 * @author YKH
 */
public class Exercise {
    //创建数组的三种方式
    public static void main(String[] args) {
        int[] arr1 = {1, 2, 3, 4, 5};
        //最常用
        int[] arr2 = new int[5];
        //未初始化，默认为0
        int[] arr3 = new int[]{1, 2, 3, 4, 5, 6, 7, 8};
        //直接初始化
        for (int x:arr2) {
            System.out.println(x+" ");
        }
    }
    //汉诺塔
    public static void move(int n,char pos1,char pos3) {
        System.out.println(n+":"+pos1 +"—>"+pos3);
    }
    public static void hannuota( int n,char pos1,char pos2,char pos3) {
        if( n==1) {
            move( n,pos1,pos3);
        } else {
            hannuota ( n-1, pos1 , pos3 , pos2);
            move ( n,pos1,pos3);
            hannuota ( n-1,pos2,pos1,pos3);
        }
    }
    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        char pos1 = 'A',pos2 ='B',pos3 ='C';
        int n = scan.nextInt();
        hannuota( n,pos1,pos2,pos3);
    }
    //模拟登陆
    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);
        String right_name = "123456789";
        String password = "987654321";
        int count = 3;
        while (scan.hasNextLine()) {
            String str1 = scan.nextLine();
            String str2 = scan.nextLine();
            if (str1.equals(right_name) && str2.equals(password)) {
                System.out.println("登陆成功");
                break;
            } else {
                count--;
                if(count == 0){
                    break;
                }
                System.out.println("输入错误，请重新输入");
            }
        }
    }
    //猜数字游戏
    public static void main1(String[] args) {
        System.out.println("请输入数字");
        Scanner scan = new Scanner(System.in);
        Random random = new Random();
        int rand = random.nextInt(150);
        System.out.println(rand);
        while(scan.hasNextInt()){
            int num = scan.nextInt();
            if( num > rand ) {
                System.out.println("猜大了");
            } else if(num == rand) {
                System.out.println("猜中了!");
                break;
            } else {
                System.out.println("猜小了");
            }
        }
        scan.close();
    }
}
